#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "pcap.h"
#include "sniffer.h"
#include<QVector>
#include"my_packge.h"

#include <QTableView>
#include <QStandardItemModel>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void show_all_devices();
    void show_state(QString state);

private:
    Ui::MainWindow *ui;
    QStandardItemModel *model;
    QString filter;
    QString capture_filter;

    pcap_if_t *all_devices;
    pcap_if_t *d;
    char errbuf[PCAP_ERRBUF_SIZE+1];

    Sniffer *sniffer;

    QVector<const unsigned char*> packges;

public slots:
    void on_comboBox_currentIndexChanged(int index);
    //用来线程间通信
    void get_packge(const unsigned char* content,struct pcap_pkthdr * header);

    void on_deleteButton_clicked();
    void on_startButton_clicked();
    void on_stopButton_clicked();
    void on_textEdit_returnPressed();
    void on_lineEdit_returnPressed();
    void tableView_cellClicked(const QModelIndex &index);
};
#endif // MAINWINDOW_H
